<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/6/28 0028
 * Time: 1:10
 */

namespace app\commands;


use yii\base\Model;

class CommonTool
{
    /**
     * 获取模型错误
     * @param Model $model
     * @return null|mixed
     */
    public static function getFirstError(Model $model)
    {
        $errors = $model->getErrors();
        if (count($errors) === 0) {
            return null;
        }
        $error = array_shift($errors);
        return $error[0];
    }
}